package net.neimeng.luculent.coremodel.base.lifecycle;

import android.arch.lifecycle.Observer;
import android.support.annotation.Nullable;

import com.blankj.utilcode.util.ToastUtils;

import net.neimeng.luculent.coremodel.datamodel.http.Result;

public abstract class LCObserver<T extends Result> implements Observer<T> {

    @Override
    public void onChanged(@Nullable T t) {
        if(t.isSuccess()){
            onSuccess(t);
            return;
        }
        onError(t);
    }

    public abstract void onSuccess(T t);

    public  void onError(T t){
        ToastUtils.showShort(t.getMessage());
    };
}
